#ifndef __MQTT_PUB__
#define __MQTT_PUB__

#include "mosquitto.h"
#include "cJSON.h"
#include <iostream>

class MqttPub
{

public:
    MqttPub();
    ~MqttPub();
    void run();

private:
    void initMqtt();
    static void onConnectCallback(struct mosquitto *mosq, void *obj, int rc);
    static void onDisconnectCallback(struct mosquitto *mosq, void *obj, int rc);
    static void onPublishCallback(struct mosquitto *mosq, void *obj, int mid);
    char *genJsonData();
    cJSON *createPointArray(double x, double y, double z);
    cJSON *createQualShapeArray(cJSON *p1, cJSON *p2, cJSON *p3, cJSON *p4);



private:
    mosquitto *mosq_;
    std::string host_ = "localhost";
    int port_ = 1883;
    int keep_alive = 60;
};

#endif